﻿<UserControl x:Class="ScrumFactory.Projects.MyDay"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:props="clr-namespace:ScrumFactory.Projects.Properties" 
             xmlns:SF_Comp="clr-namespace:ScrumFactory.Composition;assembly=ScrumFactory.Composition"
             xmlns:SF_Helpers="clr-namespace:ScrumFactory.Windows.Helpers;assembly=ScrumFactory.Windows.Helpers"
             
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
             
             x:Name="thisView"
             
             SF_Comp:CommandBehavior.RoutedEventName="Loaded"
            SF_Comp:CommandBehavior.TheCommandToRun="{Binding OnLoadCommand}">
    
    <UserControl.Resources>

        <Style x:Key="EventDescriptionTextBlock" TargetType="{x:Type TextBlock}" BasedOn="{StaticResource {x:Type TextBlock}}">
            <Style.Triggers>
                <DataTrigger Binding="{Binding EventType}" Value="0">
                    <Setter Property="TextBlock.Text" Value="{x:Static props:Resources.Project_start}"/>
                 </DataTrigger>
                <DataTrigger Binding="{Binding EventType}" Value="1">
                    <Setter Property="TextBlock.Text" Value="{Binding SprintNumber, StringFormat={x:Static props:Resources.Sprint_N_start}}"/>
                </DataTrigger>
                <DataTrigger Binding="{Binding EventType}" Value="2">
                    <Setter Property="TextBlock.Text" Value="{x:Static props:Resources.PProject_end}"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>

        <Style x:Key="NoItemsTextBlock" TargetType="{x:Type TextBlock}" BasedOn="{StaticResource {x:Type TextBlock}}">
            <Setter Property="Text" Value="{x:Static props:Resources.no_items}"/>
            <Setter Property="Foreground" Value="{StaticResource SubTextBrush}"/>            
            <Setter Property="TextBlock.Visibility" Value="Collapsed"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding .}" Value="0">
                    <Setter Property="TextBlock.Visibility" Value="Visible"/>
                </DataTrigger>                
            </Style.Triggers>
        </Style>

    </UserControl.Resources>

    
    
    <SF_Helpers:PanelLayout Title="{Binding PanelName}">

        <!--<SF_Helpers:PanelLayout.Toolbar>
            
        </SF_Helpers:PanelLayout.Toolbar>-->
        
        <SF_Helpers:PanelLayout.Content>
            <Grid>
                <Grid.Style>
                    <Style>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding IsVisible}" Value="False">
                                <Setter Property="Grid.Visibility" Value="Collapsed"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Grid.Style>
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>                    
                </Grid.ColumnDefinitions>

                <ContentControl Grid.ColumnSpan="2" Grid.Row="0" Content="{Binding PendingMembershipsListViewModel.View}"/>

                <ScrollViewer Grid.Column="0" Grid.Row="1">
                    <StackPanel Orientation="Vertical"  Margin="4">

                        <TextBlock Text="{x:Static props:Resources.My_tasks}" Style="{StaticResource GroupTextBlock}" Margin="0,10,0,5"/>
                        <ListView
                x:Name="myTasksList"
            Style="{StaticResource ListViewNoHeader}"
            SF_Helpers:ListViewColumnsExtension.Stretch="True"     
            SF_Helpers:ItemActivation.ActivationMode="Both"            
            SF_Helpers:ItemActivation.TheCommandToRun="{Binding ShowTaskDetailCommand}" 
            ItemsSource="{Binding MyTasks}">
                            <ListView.View>
                                <GridView>
                                    <GridViewColumn Width="30">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <Image Style="{StaticResource TaskTypeImage}" DataContext="{Binding TaskType}"/>
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                    <GridViewColumn>
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock >
                                    <Hyperlink Command="{Binding Model.ShowTaskDetailCommand, ElementName=thisView}" CommandParameter="{Binding .}">
                                        <TextBlock Text="{Binding TaskName}" TextTrimming="CharacterEllipsis"/>    
                                    </Hyperlink>
                                                <LineBreak/>
                                                <TextBlock Text="{Binding TaskInfo.ProjectName}" Foreground="{StaticResource SubTextBrush}" FontSize="{StaticResource SmallFontSize}"/>
                                </TextBlock>
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                    <GridViewColumn Width="80">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock 
                                    HorizontalAlignment="Right"
                                     VerticalAlignment="Center"
                                    Text="{Binding DaysOpened, StringFormat={x:Static props:Resources.N_days}}" 
                                                Foreground="{StaticResource WatermarkTextBrush}" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                </GridView>
                            </ListView.View>
                        </ListView>
                        <TextBlock Style="{StaticResource NoItemsTextBlock}" DataContext="{Binding ElementName=myTasksList, Path=Items.Count}"/>

                        <TextBlock Text="{x:Static props:Resources.My_observer_tasks}" Style="{StaticResource GroupTextBlock}" Margin="0,15,0,5"/>
                        <ListView
                x:Name="myOwnedTaskList"
            Style="{StaticResource ListViewNoHeader}"
            SF_Helpers:ItemActivation.ActivationMode="Both"            
            SF_Helpers:ItemActivation.TheCommandToRun="{Binding ShowTaskDetailCommand}"
            SF_Helpers:ListViewColumnsExtension.Stretch="True"
            ItemsSource="{Binding MyOwnedTasks}">
                            <ListView.View>
                                <GridView>
                                    <GridViewColumn Width="30">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <Image Style="{StaticResource TaskTypeImage}" DataContext="{Binding TaskType}"/>
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                   

                                    <GridViewColumn>
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock >
                                        <Hyperlink Command="{Binding Model.ShowTaskDetailCommand, ElementName=thisView}" CommandParameter="{Binding .}">
                                            <TextBlock Text="{Binding TaskName}" TextTrimming="CharacterEllipsis"/>    
                                        </Hyperlink>
                                        <LineBreak/>
                                        <TextBlock Text="{Binding TaskInfo.ProjectName}" Foreground="{StaticResource SubTextBrush}" FontSize="{StaticResource SmallFontSize}"/>
                                        <TextBlock
                                            Text="{Binding TaskAssigneeUId, StringFormat={x:Static props:Resources.assigned_to}}" 
                                            FontSize="{StaticResource SmallFontSize}" Foreground="{StaticResource SubTextBrush}" TextTrimming="CharacterEllipsis">
                                            <TextBlock.Style>
                                                <Style TargetType="TextBlock">
                                                    <Style.Triggers>
                                                        <DataTrigger Binding="{Binding TaskAssigneeUId}" Value="{x:Null}">
                                                            <Setter Property="Visibility" Value="Collapsed"/>
                                                        </DataTrigger>
                                                    </Style.Triggers>
                                                </Style>
                                            </TextBlock.Style>
                                        </TextBlock>
                                        
                                </TextBlock>
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                    <GridViewColumn Width="80">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock 
                                    HorizontalAlignment="Right"
                                     VerticalAlignment="Center"
                                    Text="{Binding DaysOpened, StringFormat={x:Static props:Resources.N_days}}" 
                                                Foreground="{StaticResource WatermarkTextBrush}" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                </GridView>
                            </ListView.View>
                        </ListView>
                        <TextBlock Style="{StaticResource NoItemsTextBlock}" DataContext="{Binding ElementName=myOwnedTaskList, Path=Items.Count}"/>


                    </StackPanel>
                </ScrollViewer>



                <ScrollViewer Grid.Column="1" Grid.Row="1">
                    <StackPanel Orientation="Vertical"  Margin="4">

                        <TextBlock Text="{x:Static props:Resources.Important_dates}" Style="{StaticResource GroupTextBlock}" Margin="0,15,0,5"/>
                        <ListView
                x:Name="eventList"
            Style="{StaticResource ListViewNoHeader}"
            SF_Helpers:ListViewColumnsExtension.Stretch="True"
            ItemsSource="{Binding ProjectEvents}">
                            <ListView.View>
                                <GridView>
                                    <GridViewColumn Width="30">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <Image Style="{StaticResource EventTypeImage}" DataContext="{Binding EventType}"/>
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                    <GridViewColumn>
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock>
                                    <Hyperlink Command="{Binding Model.ShowProjectDetailCommand, ElementName=thisView}" CommandParameter="{Binding ProjectUId}">
                                        <TextBlock Style="{StaticResource EventDescriptionTextBlock}" TextTrimming="CharacterEllipsis"/>    
                                    </Hyperlink>
                                    <LineBreak/>
                                    <TextBlock Text="{Binding ProjectName}" TextTrimming="CharacterEllipsis" FontSize="{StaticResource SmallFontSize}" Foreground="{StaticResource SubTextBrush}"/>
                                </TextBlock>
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                    <GridViewColumn Width="70">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock                                     
                               
                                    HorizontalAlignment="Right"
                                    Text="{Binding DaysLeft, StringFormat={x:Static props:Resources.N_days}}" Foreground="{StaticResource WatermarkTextBrush}"/>
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                </GridView>
                            </ListView.View>
                        </ListView>

                        <TextBlock Style="{StaticResource NoItemsTextBlock}" DataContext="{Binding ElementName=eventList, Path=Items.Count}"/>


                    </StackPanel>
                </ScrollViewer>
             

                <ContentControl Style="{StaticResource LoadingAnimationContent}"/>

            </Grid>
            
        </SF_Helpers:PanelLayout.Content>
    </SF_Helpers:PanelLayout>

   
    
    
    

    

</UserControl>
